# delimit ;
clear ;
set more off ;
est drop _all ;
cd "R:/personlig/fenellac/menarche_replication/analysis/" ;

global plusdir "R:/personlig/fenellac/stata_ado/plus/" ;
sysdir set PLUS $plusdir ;
adopath ++ $plusdir ;

* **************************************************************************** ;
* This code replicates Appendix A, Table 1.
*
* Paper: "Age of Marriage and Women's Political Engagement: Evidence from India"
* Authors: Fenella Carpena, Francesca Jensenius
* 
* Code by Fenella Carpena
* Last update: March 3, 2020
* **************************************************************************** ;

****************************************************************************** ;
* select the sample
****************************************************************************** ;

use "./input/eligible-women-ihds02-lhs.dta", clear ;
merge 1:1 IDHH PERSONID using "./input/eligible-women-ihds02-rhs.dta" ;
tab _merge ;
assert _merge == 3 ;
drop _merge ;

* keep only women who are married only once (i.e., have not ever remarried) ;
drop if ever_remarried == 1 ;
  
* keep only women age of menarche between 11-18 (1st-99th pctile) ; 
summ menarche_age ;
keep if menarche_age >= 11 & menarche_age <= 18 ;

* generating district identifier ;
egen dt_id = group(STATEID DISTID) ;

****************************************************************************** ;
* label variables for the output table 
****************************************************************************** ;

local political "attended_panchayat member_pol_org" ;

label var attended "\shortstack[l]{Attended village \\ council meeting \\ last year}" ;
label var member_pol_org "\shortstack[l]{Participates in \\ a political \\ organization}" ;

label var marriage_age "Marriage Age" ;

****************************************************************************** ;
* TABLE: OLS regression, currently married vs. no longer married women ;
****************************************************************************** ;

****************************************************************************** ;
* Panel A: Full Sample, Rural and Urban Women ;
****************************************************************************** ;
est drop _all ;

foreach var of varlist `political' { ;
 	areg `var' prev_married height_measure hindu muslim sc st obc age mother_yrs_educ father_yrs_educ years_schooling rural, a(dt_id) robust ;
	est sto `var'1 ;

 	areg `var' widowed height_measure hindu muslim sc st obc age mother_yrs_educ father_yrs_educ years_schooling rural, a(dt_id) robust ;
	est sto `var'2 ;

 	areg `var' separate  height_measure hindu muslim sc st obc age mother_yrs_educ father_yrs_educ years_schooling rural, a(dt_id) robust ;
	est sto `var'3 ;

} ;

esttab attended* member* using "./output/table-OLS-married-vs-not-married-panel-a-full.tex", 
	replace
	drop(height_measure hindu muslim sc st obc age mother_yrs_educ father_yrs_educ years_schooling _cons rural) 
	cells(b(label() star fmt(%9.3f %9.3f)) se(par)) 
	star(* 0.10 ** 0.05 *** 0.01) 
	stats(N, fmt(%9.0f) labels("Observations")) 
	prehead(\begin{table}[p]\centering `"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"'
		\captionsetup{justification=centering} 
		\caption{Previously Married vs. Currently Married Women}
		\label{table-OLS-married-vs-not-married}
		\begin{subtable}[p]{\linewidth}
		\centering
		\caption*{\normalsize Panel A: Rural and Urban Women}
		\vspace{-4ex}
		\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
		\begin{tabular*}{\hsize}{@{\hskip\tabcolsep\extracolsep\fill}lp{1.1cm}p{1.1cm}p{1.1cm}p{1.1cm}p{1.1cm}p{1.6cm}}
		\label{table-OLS-married-vs-not-married-panel-a-full} \\ 
		\toprule)
	nodepvars nomtitles
	legend label  booktabs  collabels( , none)
	mgroups(
	"\shortstack[c]{Attended village (rural) \\ or municipal (urban) \\ council meeting last year}"
	"\shortstack[c]{Participates in \\ a political \\ organization}" 
	, pattern(1 0 0 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))
	postfoot(`"\midrule"'  \end{tabular*} \end{subtable} ) ;
	
****************************************************************************** ;
* Panel B: Rural Women ;
****************************************************************************** ;

foreach var of varlist `political' { ;
 	areg `var' prev_married height_measure hindu muslim sc st obc age mother_yrs_educ father_yrs_educ years_schooling if rural == 1, a(dt_id) robust ;
	est sto `var'1 ;

 	areg `var' widowed height_measure hindu muslim sc st obc age mother_yrs_educ father_yrs_educ years_schooling if rural == 1, a(dt_id) robust ;
	est sto `var'2 ;

 	areg `var' separate  height_measure hindu muslim sc st obc age mother_yrs_educ father_yrs_educ years_schooling if rural == 1, a(dt_id) robust ;
	est sto `var'3 ;

} ;

esttab attended* member* using "./output/table-OLS-married-vs-not-married-panel-b-rural.tex", 
	replace
	drop(height_measure hindu muslim sc st obc age mother_yrs_educ father_yrs_educ years_schooling _cons) 
	cells(b(label() star fmt(%9.3f %9.3f)) se(par)) 
	star(* 0.10 ** 0.05 *** 0.01) 
	stats(N, fmt(%9.0f) labels("Observations")) 
	prehead(\smallskip
	\subcaption*{\normalsize Panel B: Rural Women}
	\label{table-OLS-married-vs-not-married-panel-b-rural} \vspace{-2ex}
	\begin{tabular*}{\hsize}{@{\hskip\tabcolsep\extracolsep\fill}lp{1.1cm}p{1.1cm}p{1.1cm}p{1.1cm}p{1.1cm}p{1.6cm}}  
	\midrule)
	nodepvars nomtitles
	legend label  booktabs  collabels( , none)
	postfoot(`"\midrule"'  \end{tabular*}) ;

****************************************************************************** ;
* Panel C: Urban Women ;
****************************************************************************** ;
est drop _all ;

foreach var of varlist `political' { ;
 	areg `var' prev_married height_measure hindu muslim sc st obc age mother_yrs_educ father_yrs_educ years_schooling if rural == 0, a(dt_id) robust ;
	est sto `var'1 ;

 	areg `var' widowed height_measure hindu muslim sc st obc age mother_yrs_educ father_yrs_educ years_schooling if rural == 0, a(dt_id) robust ;
	est sto `var'2 ;

 	areg `var' separate  height_measure hindu muslim sc st obc age mother_yrs_educ father_yrs_educ years_schooling if rural == 0, a(dt_id) robust ;
	est sto `var'3 ;

} ;

esttab attended* member* using "./output/table-OLS-married-vs-not-married-panel-c-urban.tex", 
	replace
	drop(height_measure hindu muslim sc st obc age mother_yrs_educ father_yrs_educ years_schooling _cons) 
	cells(b(label() star fmt(%9.3f %9.3f)) se(par)) 
	star(* 0.10 ** 0.05 *** 0.01) 
	stats(N, fmt(%9.0f) labels("Observations")) 
	prehead(\smallskip
	\subcaption*{\normalsize Panel C: Urban Women}
	\label{table-OLS-married-vs-not-married-panel-c-urban} \vspace{-2ex}
	\begin{tabular*}{\hsize}{@{\hskip\tabcolsep\extracolsep\fill}lp{1.1cm}p{1.1cm}p{1.1cm}p{1.1cm}p{1.1cm}p{1.6cm}} 
	\midrule)
	nodepvars nomtitles
	legend label  booktabs  collabels( , none)
	postfoot(`"\bottomrule"'  \end{tabular*} 
	\captionsetup{justification=justified}
	\caption*{\small \textit{Notes:} 
		OLS regression. Data from IHDS 2011--12. \textit{Widow/Separated/Divorced} is a dummy variable
		equal to 1 if the respondent is separated, divorced or widow, and 0 if the respondent is currently married.
		The dummy variables \textit{Widow} and \textit{Separated/Divorced} are defined similarly. 	
		The data contain 1053 widows (of whom 676 live in rural areas) and 136 separated/divorced women (of whom 91 live in rural areas). The outcome variable \textit{Discusses politics and community with husband}
		is not included in this table as it does not apply to women who are no longer married.
		All regressions include district FEs, height, age, education, parents' education, household caste, religion. 
		Regressions in Panel A include a rural dummy.
		Robust SEs in parenthesis. ***\$\,p < 0.01$, **\$\,p < 0.05$, *\$\,p<0.10$.\looseness=-1}
	\end{table}) ;

exit ;
	

